package com.company.arithmetic;

/**
 * Created by v on 16-12-19.
 */
public class MatrixMultiplication {
    //不允许创建其对象
    private MatrixMultiplication(){};

    //基础的O(n^3)矩阵乘法
    public static int[][] multiply(int[][] a,int[][] b){
        int m=a.length;
        int p=a[0].length;
        int n=b[0].length;

        int[][] c=new int[m][n];

        for(int i=0;i<m;i++){
            for(int j=0;j<n;j++){
                for(int k=0;k<p;k++){
                    c[i][j]+=a[i][k]*b[k][j];
                }
            }
        }

        return c;
    }
}
